


clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear
********************************************************************************
*****Table 3/ Naive Estimates***************************************************
********************************************************************************

********************************************************************************
*Panel A; Columns 1 and 3
********************************************************************************
preserve
local deps "  newbw2500   newpretermLT37  "
 foreach item in `deps' {

reg `item' T i.by  i.mom_birth_state     , cluster(mom_birth_state)
eststo 
sum `item' if e(sample)==1
estadd scalar depvarmean = r(mean)
}

esttab using "Table3_PanelA_c1_c3.csv", append ///
se b(%9.3f) scalars (depvarmean ) keep(T) ///
label title(OLS_`item')  mtitles(   "newbw2500"   "newpretermLT37"  ) starlevels(* 0.1 ** .05 *** .01)   ///

eststo clear
restore

********************************************************************************
*Panel A; Columns 2 and 4
********************************************************************************
preserve
local deps "  newbw2500   newpretermLT37  "
 foreach item in `deps' {

reg `item' T i.age_cat i.tbo i.male  i.division#c.by i.by i.mom_birth_state Exitexam i.birth_month i.year Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate, cluster(mom_birth_state)
eststo 
sum `item' if e(sample)==1
estadd scalar depvarmean = r(mean)
}

esttab using "Table3_PanelA_c2_c4.csv", append ///
se b(%9.3f) scalars (depvarmean ) keep(T) ///
label title(OLS_`item')  mtitles(   "newbw2500"   "newpretermLT37"  ) starlevels(* 0.1 ** .05 *** .01)   ///

eststo clear
restore

********************************************************************************
*Panel B; Columns 1 and 3
********************************************************************************
preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4

local deps "   newbw2500   newpretermLT37   "
 foreach item in `deps' {

reg `item' Post0 Post1 Post2 Post3 Post4    i.by   i.mom_birth_state, cluster(mom_birth_state)
eststo 
sum `item' if e(sample)==1
estadd scalar depvarmean = r(mean)
}
 esttab using "Table3_PanelB_c1_c3.csv", append ///
se b(%9.3f) scalars ( depvarmean) keep(plus0 plus1 plus2 plus3 plus4 ) ///
label title(OLS_`item')  mtitles(   "newbw2500"   "newpretermLT37"  ) starlevels(* 0.1 ** .05 *** .01)   ///

eststo clear
restore



********************************************************************************
*Panel B; Columns 2 and 4
********************************************************************************
preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4

local deps "   newbw2500   newpretermLT37   "
 foreach item in `deps' {

reg `item' Post0 Post1 Post2 Post3 Post4    i.by i.age_cat  i.mom_birth_state  i.birth_month i.year i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by , cluster(mom_birth_state)
eststo 
sum `item' if e(sample)==1
estadd scalar depvarmean = r(mean)
}
 esttab using "Table3_PanelB_c2_c4.csv", append ///
se b(%9.3f) scalars ( depvarmean) keep(plus0 plus1 plus2 plus3 plus4 ) ///
label title(OLS_`item')  mtitles(   "newbw2500"   "newpretermLT37"  ) starlevels(* 0.1 ** .05 *** .01)   ///

eststo clear
restore
********************************************************************************
*****Table 3/ Weighted Estimates************************************************
********************************************************************************

********************************************************************************
*Panel A; Column 1 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear


preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
 reg newbw2500 $treat_var i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************

set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_3_panela_c1_weighted", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui  reg newbw2500 $treat_var i.by i.mom_birth_state
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo


use table_3_panela_c1_weighted, clear

sum /****Std Dev is the standard error of the weighted point estimate.*/


********************************************************************************
*Panel A; Column 3 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear

preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
 reg newpretermLT37 $treat_var i.by i.mom_birth_state, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************
set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_3_panela_c3_weighted", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui  reg newpretermLT37 $treat_var i.by i.mom_birth_state
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_3_panela_c3_weighted, clear

sum /****Std Dev is the standard error of the weighted point estimate.*/




********************************************************************************
*Panel A; Column 2 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear

preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newbw2500 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by i.by i.mom_birth_state i.year i.birth_month, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************
set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_3_panela_c2_weighted", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newbw2500 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.by i.mom_birth_state i.year i.birth_month 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_3_panela_c2_weighted, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/

********************************************************************************
*Panel A; Column 4 
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear

preserve
gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}

reg newpretermLT37 $treat_var $state_var i.age_cat i.tbo i.male  i.division#c.by i.by i.mom_birth_state i.year i.birth_month, cluster(mom_birth_state)

local Z=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
lincom (_b[Post0]*meanPost0/`Z')+(_b[Post1]*meanPost1/`Z')+(_b[Post2]*meanPost2/`Z')+(_b[Post3]*meanPost3/`Z')+(_b[Post4]*meanPost4/`Z')
restore
********************************************************************************
set seed 23260513
capture postclose placebo		  
postfile placebo b using "$data/table_3_panela_c4_weighted", replace
forvalues i=1/500 {
use $data/estimation_sample_blacks, clear


preserve
bsample, cluster(mom_birth_state)

gen Post0=0
replace Post0=1 if index==0

gen Post1=0
replace Post1=1 if index==1

gen Post2=0
replace Post2=1 if index==2

gen Post3=0
replace Post3=1 if index==3

gen Post4=0
replace Post4=1 if index>=4


global treat_var "Post0 Post1 Post2 Post3 Post4"
global state_var "Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate"
foreach x in $treat_var{
sum `x', meanonly
scalar mean`x'=r(mean)
}
qui reg newpretermLT37 $treat_var $state_var i.age_cat  i.tbo i.male  i.division#c.by i.by i.mom_birth_state i.year i.birth_month 
local V=meanPost0+meanPost1+meanPost2+meanPost3+meanPost4
local c_weighted=(_b[Post0]*meanPost0/`V')+(_b[Post1]*meanPost1/`V')+(_b[Post2]*meanPost2/`V')+(_b[Post3]*meanPost3/`V')+(_b[Post4]*meanPost4/`V')
post placebo (`c_weighted')
restore
}

postclose placebo

use table_3_panela_c4_weighted, clear

sum  /****Std Dev is the standard error of the weighted point estimate.*/
